package com.vercon.moensmart.dialog

import android.text.Html
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.vercon.moensmart.dialog.base.BaseDialogFragment
import com.vercon.moensmart.R
import com.vercon.moensmart.databinding.DialogDeleteBinding


class DeleteDialog : BaseDialogFragment<DialogDeleteBinding>() {
    private var mContent: String? = null
    private var mOnDeleteDialogListener: OnDeleteDialogListener? = null


    fun setString(content: String?) {
        mContent = content
    }

    override fun onCreateViewBinding(inflater: LayoutInflater, parent: ViewGroup?): DialogDeleteBinding {
        return DialogDeleteBinding.inflate(inflater,parent,false)
    }

    override fun initView(view: View?) {
       binding?.tvContent?.text = Html.fromHtml(mContent)
    }

    override fun initListener(view: View?) {
        view?.findViewById<View>(R.id.btn_no_commit)?.setOnClickListener { v: View? -> dismiss() }
        view?.findViewById<View>(R.id.btn_commit)?.setOnClickListener { v: View? ->
            if (mOnDeleteDialogListener != null) {
                mOnDeleteDialogListener!!.delete()
            }
        }
    }

    override val isFullScreen: Boolean
        get() = false

    fun setOnDeleteDialogListener(listener: OnDeleteDialogListener) {
        mOnDeleteDialogListener = listener
    }

    interface OnDeleteDialogListener {
        fun delete()
    }
}